package iks.utils.ui
{
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.media.*;
	import iks.sound.*;
	
	/**
	 * 加强型BMPButton对象, 拥有禁用功能和图案
	 * @author StefanieKaka
	 */
	public class BMPButtonEx extends BMPButton
	{
		/**
		 * 构造函数
		 */
		public function BMPButtonEx(out : Bitmap, over : Bitmap, forbid : Bitmap,
							overSound : KSound = null, clickSound : KSound = null)
		{
			super(out, over, overSound, clickSound);
			m_forbid = forbid;
			this.addChild(m_forbid);
			enabled = true;
		}
	
		/**
		 * 获得/设置按钮是否能使用
		 */
		public function get enabled() : Boolean
		{
			return m_enabled;
		}
		
		public function set enabled(value : Boolean) : void
		{
			m_enabled = value;
			
			if (m_enabled)
			{
				var rect : Rectangle = new Rectangle(0, 0, this.width, this.height);
				if (rect.containsPoint(new Point(this.mouseX, this.mouseY)))
				{
					m_bmpOver.x = 0;
					m_bmpOver.y = 0;
					m_bmpOver.visible = true;
				}
				else
				{
					m_bmpOut.x = 0;
					m_bmpOut.y = 0;
					m_bmpOut.visible = true;
				}
				
				m_forbid.visible = false;
				this.mouseChildren = true;
				this.mouseEnabled = true;
			}
			else
			{
				m_forbid.visible = true;
				m_bmpOut.visible = false;
				m_bmpOver.visible = false;
				this.mouseChildren = false;
				this.mouseEnabled = false;
			}
		}
		
///////////////////////////////////////////////////////////////////////////////////////////////////
// 私有域
///////////////////////////////////////////////////////////////////////////////////////////////////
		
		private var m_forbid : Bitmap = null;
		private var m_enabled : Boolean = true;
	}

}






































///////////////////////////////////////////////////////////////////////////////////////////////////
// end file


